﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AlexandriaPressUserBusinessLayer;
using System.Data;

namespace AlexandriaPressWebsite.MasterPages.UserPages
{
    public partial class UserTransactionsPage : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.Name != "")
            {
                UserBusinsessLayer business = new UserBusinsessLayer();
                string _UserType = business.getUserType(HttpContext.Current.User.Identity.Name);
                if (_UserType == "Type_Buyer" || _UserType == "Type_Admin" || _UserType == "Type_ProofReader" || _UserType == "Type_Author")
                {
                    
                }
                else
                {
                    Response.Redirect("~/MasterPages/ErrorPage.aspx");
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {


                if (Session["blocked"] != null)
                {
                    Session.RemoveAll();
                    Response.Redirect("~/MasterPages/MainPage.aspx");
                }
                else
                {
                    string username = (HttpContext.Current.User.Identity.Name);

                    UserBusinsessLayer business = new UserBusinsessLayer();
                    DataTable table = business.transView(business.myTransactions(username));
                    transGridView1.DataSource = table;
                    transGridView1.EmptyDataText = "No transactions made.";
                    transGridView1.DataBind();
                }
        }
    }
}
